﻿namespace HuwmanCode.Diagnostics.Logging

open System

/// <summary>
/// The interface for a trace
/// </summary>
type ITrace =
    /// <summary>
    /// Writes the specified message to the Trace.
    /// </summary>
    /// <param name="message">The message.</param>
    abstract Write: message:Object -> unit

    /// <summary>
    /// Writes the specified message to the Trace.
    /// </summary>
    /// <param name="message">The message.</param>
    /// <param name="exn">The exception.</param>
    abstract Write: message:Object * exn:Exception -> unit 

    /// <summary>
    /// Writes the specified message to the Trace.
    /// </summary>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    abstract WriteFormat: format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Writes the specified message to the Trace.
    /// </summary>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    /// <param name="exn">The exception.</param>
    abstract WriteFormatEx: exn:Exception * format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Writes the specified message to the Trace.
    /// </summary>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    abstract WriteFormat: formatProvider:IFormatProvider * format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Writes the specified message to the Trace.
    /// </summary>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    /// <param name="exn">The exception.</param>
    abstract WriteFormatEx: exn:Exception * formatProvider:IFormatProvider * format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Writes the specified message to the Trace when the ambient transaction commits.
    /// </summary>
    /// <param name="message">The message.</param>
    abstract WriteOnCommit: message:Object -> unit

    /// <summary>
    /// Writes the specified message to the Trace when the ambient transaction commits.
    /// </summary>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    abstract WriteFormatOnCommit: format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Writes the specified message to the Trace when the ambient transaction commits.
    /// </summary>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    abstract WriteFormatOnCommit: formatProvider:IFormatProvider * format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Writes the specified message to the Trace when the ambient transaction rolls back.
    /// </summary>
    /// <param name="message">The message.</param>
    abstract WriteOnRollback: message:Object -> unit

    /// <summary>
    /// Writes the specified message to the Trace when the ambient transaction rolls back.
    /// </summary>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    abstract WriteFormatOnRollback: format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Writes the specified message to the Trace when the ambient transaction rolls back.
    /// </summary>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The format.</param>
    /// <param name="args">The args.</param>
    abstract WriteFormatOnRollback: formatProvider:IFormatProvider * format:String * [<ParamArray>] args:Object array -> unit

    /// <summary>
    /// Tries the action then writes any error to the Trace.
    /// </summary>
    /// <param name="action">The action.</param>
    /// <param name="failureMessage">The failure message.</param>
    abstract WriteOnActionError: action:Action * failureMessage:String -> Option<unit>

    /// <summary>
    /// Tries the action then writes any error to the Trace.
    /// </summary>
    /// <param name="action">The action.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    abstract WriteFormatOnActionError: action:Action * format:String * [<ParamArray>] args:Object array -> Option<unit>

    /// <summary>
    /// Tries the action then writes any error to the Trace.
    /// </summary>
    /// <param name="action">The action.</param>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    abstract WriteFormatOnActionError: action:Action * formatProvider:IFormatProvider *  format:String * [<ParamArray>] args:Object array -> Option<unit>

    /// <summary>
    /// Tries the action then writes any error to the Trace, thereafter reraises the error.
    /// </summary>
    /// <param name="action">The action.</param>
    /// <param name="failureMessage">The failure message.</param>
    abstract WriteOnActionErrorReraise: action:Action * failureMessage:String -> unit

    /// <summary>
    /// Tries the action then writes any error to the Trace, thereafter reraises the error.
    /// </summary>
    /// <param name="action">The action.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    abstract WriteFormatOnActionErrorReraise: action:Action * format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Tries the action then writes any error to the Trace, thereafter reraises the error.
    /// </summary>
    /// <param name="action">The action.</param>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    abstract WriteFormatOnActionErrorReraise: action:Action * formatProvider:IFormatProvider *  format:String * [<ParamArray>] args:Object array -> unit 

    /// <summary>
    /// Tries the function then writes any error to the Trace.
    /// </summary>
    /// <param name="func">The function.</param>
    /// <param name="failureMessage">The failure message.</param>
    /// <returns>The function success</returns>
    abstract WriteOnFunctionError: func:Func<'a> * failureMessage:String -> 'a Option

    /// <summary>
    /// Tries the function then writes any error to the Trace.
    /// </summary>
    /// <param name="func">The function.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    /// <returns>The function success</returns>
    abstract WriteFormatOnFunctionError: func:Func<'a> * format:String * [<ParamArray>] args:Object array -> 'a Option 

    /// <summary>
    /// Tries the function then writes any error to the Trace.
    /// </summary>
    /// <param name="func">The function.</param>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    /// <returns>The function success</returns>
    abstract WriteFormatOnFunctionError: func:Func<'a> * formatProvider:IFormatProvider *  format:String * [<ParamArray>] args:Object array -> 'a Option 

    /// <summary>
    /// Tries the function then writes any error to the Trace, thereafter reraises the error.
    /// </summary>
    /// <param name="func">The function.</param>
    /// <param name="failureMessage">The failure message.</param>
    abstract WriteOnFunctionErrorReraise: func:Func<'a> * failureMessage:String -> 'a

    /// <summary>
    /// Tries the function then writes any error to the Trace, thereafter reraises the error.
    /// </summary>
    /// <param name="func">The function.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    abstract WriteFormatOnFunctionErrorReraise: func:Func<'a> * format:String * [<ParamArray>] args:Object array -> 'a 

    /// <summary>
    /// Tries the function then writes any error to the Trace, thereafter reraises the error.
    /// </summary>
    /// <param name="func">The function.</param>
    /// <param name="formatProvider">The format provider.</param>
    /// <param name="format">The failure message format.</param>
    /// <param name="args">The failure message formatting args.</param>
    abstract WriteFormatOnFunctionErrorReraise: func:Func<'a> * formatProvider:IFormatProvider *  format:String * [<ParamArray>] args:Object array -> 'a 